/******************************************************************************/
/** \file os_types.h
 **
 ** os type common define.
 ** @link SampleGroup Some description @endlink
 **
 **   - 2020-11-07  1.0  LFZ First version.
 **
 ******************************************************************************/

#ifndef __OS_MQ_H__
#define __OS_MQ_H__

#ifdef __cplusplus
extern "C" {
#endif
#include "os_types.h"
#ifdef RT_THREAD_ENABLE
#include <rtthread.h>
typedef struct rt_messagequeue os_mq;
typedef struct rt_messagequeue *os_mq_t;
#endif

/*标注消息的数据结构体*/
typedef struct
{
	uint8_t  		mq_type;			    //消息的类型
	uint16_t		mq_data_len;			//带数据的消息的长度
	void*		  	mq_pt_data;				//带数据的消息的数据
}os_mq_data;

typedef os_mq_data* os_mq_data_pt;

BOOL os_mq_init(os_mq_t mq, const char *name, void *mq_pool_pt, uint32_t mq_pool_size);
BOOL os_mq_detach(os_mq_t mq);

os_mq_t os_mq_create(const char *name, uint32_t  max_msgs);
BOOL os_mq_delete(os_mq_t mq);

BOOL os_mq_get_mem(os_mq_data_pt pt_msg, uint8_t u8msg_type, const uint16_t u16size);
void os_mq_free_mem(os_mq_data_pt pt_msg);

BOOL os_mq_send(os_mq_t mq, os_mq_data_pt pt_msg, BOOL gent_en);
BOOL os_mq_recv(os_mq_t mq, os_mq_data_pt pt_msg, uint32_t timeout);

BOOL os_mq_reset(os_mq_t mq);
#ifdef __cplusplus  // close out "C" linkage in case of c++ compiling
}
#endif

#endif /* __OS_TYPES_H__ */

/******************************************************************************/
/* EOF (not truncated)                                                        */
/******************************************************************************/



